//用队列控制多个动画播放
using DG.Tweening;
using UnityEngine;

public class DOTweenSequence : MonoBehaviour
{
    private Sequence mSequence;
    public Transform mCube;
    
    void Start()
    {
        mSequence = DOTween.Sequence();
        mSequence.Append(mCube.DOMove(Vector3.one, 1)); //插入队列后进行播放，最常用
        mSequence.Join(mCube.DOScale(Vector3.one * 2, 1)); //插入队列中进行播放，特殊情况使用
        mSequence.AppendCallback(() => { Debug.Log("这里执行回调"); });
        mSequence.AppendInterval(1);
        mSequence.Append(mCube.DOMove(new Vector3(-1,0,0), 1));
        mSequence.Join(mCube.DOScale(Vector3.one, 1));

        mSequence.PrependInterval(1);   //插入队列前面进行播放，特殊情况使用
        mSequence.PrependCallback((() =>
        {
            Debug.Log("这里预先调用方法");
        }));
        mSequence.Prepend(mCube.DOMove(Vector3.one, 1));

        mSequence.InsertCallback(5, () => { Debug.Log("第五秒执行方法");});

    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            mSequence.Insert(1,mCube.DORotate(Vector3.up * 180, 1));
        }
    }
}
